package com.leyou.page.web;

import com.leyou.page.service.PageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

@Controller
@Slf4j
public class PageController {

    @Autowired
    PageService pageService;

    @GetMapping("/item/{id}.html")
    public String querySpuBySpuId(Model model, @PathVariable("id") Long spuId) {
        Map<String, Object> models = pageService.querySpuBySpuId(spuId);
        model.addAllAttributes(models);
        return "item";
    }
}
